<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="nst" uri="http://www.nstechs.com/app/core"%>
<%@ page isELIgnored="false" %>

<script>
var rootPath = "${pageContext.request.contextPath}";
	$(document).ready(function() {

		$('.back').click(function() {
			window.location = rootPath+"/article/list";
		});

		$("#Name").blur(function() {
			var name = $("#Name").val().trim();
			var desc = $("#Description").val().trim();
			if (name == "") {
				$(".name-valid").html(" * name is needed");
			} else {
				$(".name-valid").html("");
			}
		});

		$("#Description").blur(function() {
			var desc = $("#Description").val().trim();
			if (desc == "") {
				$(".desc-valid").html(" * description is needed");
			} else {
				$(".desc-valid").html("");
			}
		});

		$(".modify").click(function() {
			var name = $("#Name").val().trim();
			var desc = $("#Description").val().trim();
			if (name == "") {
				$(".name-valid").html(" * name is needed");
				$("#Name").focus();
				return;
			}
			if (desc == "") {
				$(".desc-valid").html(" * description is needed");
				return;
			}
			$(".name-valid").html("");
			$(".desc-valid").html("");
			if (desc != "" && name != "") {
				$("#navigationForm").submit();
			}
		});
	});
</script>


<div id="main">
	<div class="content">
		<h2>add article</h2>
		<form method="post" id="navigationForm" action="article">
			<ul>
				<li><label for="Name"> title<span
						class="required">*</span>
				</label> <input id="title" name="title" type="text"> <span
					class="name-valid" style="color:red;"></span></li>

	

				<li><label for="content">content</label> <textarea
						id="content" cols="20" rows="2" name="content""></textarea>
					<span class="desc-valid" style="color:red;"></span></li>
				<li class="btnline"><input class="modifyv" value="Modify"
					type="submit"> &nbsp; <input class="back" value="back list"
					type="button"></li>
			</ul>
		</form>
	</div>
</div>